"""
鼠标的拖拽
"""
import time

from robot.parsing.lexer.statementlexers import ElseHeaderLexer
from selenium import webdriver
from selenium.webdriver import  ActionChains
from selenium.webdriver.common.by import By
driver=webdriver.Edge()
driver.maximize_window()
driver.get("http://localhost:8081/drag.html")
hongse=driver.find_element(By.CSS_SELECTOR,"#div1")
lanse=driver.find_element(By.CSS_SELECTOR,"#div2")

# # 1 通过ActionChains类创建鼠标对象
action=ActionChains(driver)
# # 2 执行鼠标操作事件   拖动
# action.drag_and_drop(hongse,lanse)  #鼠标的拖动

# 按照偏移量进行拖拽元素
action.drag_and_drop_by_offset(hongse,0,0)  #鼠标的拖动

# # 3 调用鼠标执行的方法
action.perform()

# 4 关闭浏览器驱动对象
time.sleep(30)  #代码暂停10s中
driver.quit()




